package com.victualler.product.employee.controller.impl;

import com.victualler.core.base.controller.impl.BaseRestControllerImpl;
import com.victualler.core.common.dto.PageDto;
import com.victualler.product.employee.controller.EmployeeController;
import com.victualler.product.employee.dto.EmployeeInfoDto;
import com.victualler.product.employee.dto.request.EmployeeRequestDto;
import com.victualler.product.employee.entity.EmployeeDao;
import com.victualler.product.employee.repository.EmployeeQueryRepository;
import com.victualler.product.employee.repository.EmployeeRepository;
import com.victualler.product.employee.service.EmployeeService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Guoshichang
 * @discription:    
 */
@RestController
@RequestMapping("/product/employee")
public class EmployeeControllerImpl extends BaseRestControllerImpl<EmployeeDao,EmployeeRepository,EmployeeQueryRepository,EmployeeService> implements EmployeeController {

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param employeeRequestDto 请求对象
     * @Function  根据条件入参employeeRequestDto动态分页查询权限
     */
    @RequestMapping("/getByRequestDto")
    public PageDto<EmployeeDao> getByRequestDto(@RequestBody EmployeeRequestDto employeeRequestDto, @RequestParam("pageNo") int pageNo, @RequestParam("limit") int limit) {
        return this.baseService.getByRequestDto(employeeRequestDto,pageNo,limit);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id 员工全部信息
     * @Function 根据id获取所有信息
     */
    @RequestMapping("/findInfoDto/{id}")
    public EmployeeInfoDto findInfoDto(@PathVariable("id") Long id) {
        return this.baseService.findInfoDto(id);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param employeeInfoDto 员工全部信息
     * @Function 保存员工大对象
     */
    @RequestMapping("/saveInfo")
    public void saveInfo(@RequestBody EmployeeInfoDto employeeInfoDto) {
        this.baseService.saveInfo(employeeInfoDto);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id 员工id
     * @param loginAccount 登陆账号
     * @Function 绑定员工账号
     */
    @RequestMapping("/bindAccountNo")
    public void bindAccountNo(@RequestParam("id") Long id,@RequestParam("loginAccount") String loginAccount) {
        this.baseService.bindAccountNo(id,loginAccount);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param loginAccount 登陆账号
     * @Function 根据账号获取对应员工
     */
    @RequestMapping("/getByLoginAccount")
    public EmployeeDao getByLoginAccount(@RequestParam("loginAccount") String loginAccount) {
        return this.baseService.getByLoginAccount(loginAccount);
    }
}
